{% extends "base.html" %}
{% import "_macros.html" as macros %}

{% block title %}Fly - 用户评论{% endblock %}

{% block page_content %}
{% include '_userbase.html' %}

<div class="btn-group">
<a href="{{ url_for('.user',username=user.username)}}" class="btn btn-default" >{{ user.posts.count() }}篇博客</a>
<a href="{{ url_for('.usercomments',username=user.username)}}" class="btn btn-info">{{ user.comments.count() }}条评论</a>
<a href="{{ url_for('.starposts', username=user.username) }}" class="btn btn-default">{{ user.starposts.__len__() }}篇收藏</a>
</div>
</br>

{% if current_user != user%} 
<ul class="comments">
        {% for comment in comments %}
            {% if comment.author == user  %}
            <li class="comment">
                <div class="comment-thumbnail">
                    <a href="{{ url_for('.user', username=comment.author.username) }}">
                        <img class="img-rounded profile-thumbnail" src="{{ comment.author.gravatar(size=40) }}">
                    </a>
                </div>
                <div class="comment-content">
                    <div class="comment-date">{{ moment(comment.timestamp).fromNow() }}</div>
                    <div class="comment-author"><a href="{{ url_for('.user', username=comment.author.username) }}">{{ comment.author.username }}</a></div> 
                        <div class="post link">
                            评论了博客:
                            <a href="{{url_for('.post',id=comment.post_id)}}">{{comment.post.head}}</a>                       
                        </div>
                        <div class="comment-body"> 
                            {% if comment.disabled %}
                            <p><i>This comment has been disabled by a moderator.</i></p>
                            {% endif %}
                            {% if moderate or not comment.disabled %}
                                {% if comment.body_html %}
                                    {{ comment.body_html | safe }}
                                {% else %}
                                    {{ comment.body }}
                                {% endif %}
                            {% endif %} 
                        </div>
                </div>
            </li>
            {% endif %}
        {% endfor %}

{% elif current_user==user %}
    <ul class="comments">
        {% for comment in comments %}
            {% if comment.author == current_user  %}
            <li class="comment">
                <div class="comment-thumbnail">
                    <a href="{{ url_for('.user', username=comment.author.username) }}">
                        <img class="img-rounded profile-thumbnail" src="{{ comment.author.gravatar(size=40) }}">
                    </a>
                </div>
                <div class="comment-content">
                    <div class="comment-date">{{ moment(comment.timestamp).format('L') }}</div>
                    <div class="comment-author"><a href="{{ url_for('.user', username=comment.author.username) }}">{{ comment.author.username }}</a></div> 
                        <div class="post link">
                            我评论了博客:
                            <a href="{{url_for('.post',id=comment.post_id)}}">{{comment.post.head}}</a>                       
                        </div>
                        <div class="comment-body">
                            {% if comment.disabled %}
                            <p><i>This comment has been disabled by a moderator.</i></p>
                            {% endif %}
                            {% if moderate or not comment.disabled %}
                                {% if comment.body_html %}
                                    {{ comment.body_html | safe }}
                                {% else %}
                                    {{ comment.body }}
                                {% endif %}
                            {% endif %}
                            <br>
                            <a href="{{ url_for('.usercomments_delete', id=comment.id, page=page) }}" class="btn btn-danger btn-xs">删除</a>
                        </div> 
                    <br>                              
                </div>
            </li>
            {% endif %}
        {% endfor %}
        </ul>
{% endif %}

{% if pagination %}
<div class="pagination">
    {{ macros.pagination_widget(pagination, '.moderate') }}
</div>
{% endif %}
{% endblock %}
